home *** CD-ROM | disk | FTP | other *** search
/ Megaware 1 / Megaware Volume 1.iso / programg / c-tutor / answers / ch04_2.cpp < prev    next >
C/C++ Source or Header  |  1990-07-20  |  893b  |  40 lines

  1.                               // Chapter 4 - Programming exercise 2
  2. #include "iostream.h"
  3.  
  4. void do_stuff(float wings, float feet, char eyes);
  5.  
  6. main()
  7. {
  8. int arm = 2;
  9. float foot = 1000.0;
  10. char lookers = 2;
  11.  
  12.    do_stuff(3, 12.0, 4);
  13.    do_stuff(arm, foot, lookers);
  14. }
  15.  
  16. void do_stuff(float wings, float feet, char eyes)
  17. {
  18.    cout << "There are " << wings << " wings." << "\n";
  19.    cout << "There are " << feet << " feet." << "\n";
  20.    cout << "There are " << eyes << " eyes." << "\n\n";
  21. }
  22.  
  23.  
  24.  
  25.  
  26. // Result of execution
  27. //
  28. // There are 3 wings.
  29. // There are 12 feet.
  30. // There are 4 eyes.
  31. //
  32. // There are 2 wings.
  33. // There are 1000 feet.
  34. // There are 2 eyes.
  35.  
  36. // There is no change in the result because int and float are
  37. //  compatible types and the system will change from one to 
  38. //  the other automatically.  Note the funny output of the
  39. //  char type however.
  40.